package com.lovegu.generic;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 老顾
 * @title: Test
 * @projectName java-restudy
 * @email: 1437594522@qq.com
 * @date 2022/9/24 15:50
 */
public class Test {
    public static void main(String[] args) {
        List<?> list = null;
        list = new ArrayList<String>();
        list = new ArrayList<Double>();
        // list.add(3);//编译不通过
        list.add(null);
        List<String> l1 = new ArrayList<String>();
        List<Integer> l2 = new ArrayList<Integer>();
        l1.add("尚硅谷");
        l2.add(15);
        read(l1);
        read(l2);
    }
    public static void read(List<?> list) {
        for (Object o : list) {
            System.out.println(o);
        }
    }
}
